<template>
	<view class="content">
		<web-view v-if="url" :src="url" @message="bindmessage"></web-view>
	</view>
</template>

<script>
	var that
	export default {
		data() {
			return {
				url: ''
			}
		},
		onLoad(e) {
			that = this
			let jsonParam = JSON.parse(decodeURIComponent(e.url));
			that.url = jsonParam
		},
		methods: {
			bindmessage(event) {
				const dataLength = (event.detail.data && event.detail.data.length) || '';
				if (!dataLength) {
					return;
				}
				const {
					eidToken,
					eidBackUrl
				} = event.detail.data[dataLength - 1];
				if (eidToken) {
					eidBackUrl && wx.setStorageSync('eidBackUrl', eidBackUrl);
					wx.navigateToMiniProgram({
						appId: 'wxa0a9f6f0154bbe7d',
						path: 'pages/authPage/auth',
						extraData: {
							token: eidToken,
						},
						envVersion: 'release',
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 40rpx;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 28rpx;
		color: $u-content-color;
	}

	.link-demo {
		margin-top: 80rpx;
	}
</style>
